import { InjectionKey } from 'vue'
import { defineStore } from 'pinia'
import { createStore, useStore as baseUseStore, Store } from 'vuex'
import user, { UserState } from '@/store/modules/user'
import tabs, { TabsState } from '@/store/modules/tabs'
import menu, { MenuState } from '@/store/modules/menu'
import { CommonStore } from './help'
import { ITab } from './type'
export type RootState = {
  user: UserState,
  tabs: TabsState,
  menu: MenuState,
}
export interface State {
  count: number,
  collapse: boolean,
  tabsList: Array<ITab>
}
export const modules = {
  user: user,
  tabs: tabs,
  menu: menu
}
export const uploadStore = defineStore('upload', {
  state: () => ({
    multiFileList: [],
    processNumber: 3,
    promise: []
  }),
  actions: {
    init() {
      this.promise = []
      this.multiFileList = []
    }
  }
})
export const key: InjectionKey<Store<State>> = Symbol() // 构造一个唯一的 key值
export const store = createStore<RootState>({
  modules
}) as CommonStore
export function useStore() {
  return baseUseStore(key)
}